#include "originator.h"
#include "memento.h"
Originator::Originator(Originator::State state, int lifeValue, int attackValue, int defenceValue)
    : m_state(state), m_lifeValue(lifeValue),
      m_attackValue(attackValue), m_defenceValue(defenceValue)
{
}
void Originator::setAll(Originator::State state, int lifeValue, int attackValue, int defenceValue)
{
    this->m_state=state;
    this->m_lifeValue=lifeValue;
    this->m_attackValue=attackValue;
    this->m_defenceValue=defenceValue;
}
std::shared_ptr<Memento> Originator::saveState()
{
    std::shared_ptr<Memento> mementor = std::make_shared<Memento>(m_state, m_lifeValue, m_attackValue, m_defenceValue);
    return mementor;
}
void Originator::setMemento(std::shared_ptr<Memento> memento)
{
    if (memento==nullptr){
        return;
    }
    this->m_state = memento->getState();
    this->m_lifeValue = memento->getLifeValue();
    this->m_attackValue = memento->getAttackValue();
    this->m_defenceValue = memento->getDefenceValue();
}
void Originator::displayState()
{
    std::cout << "m_state:" << m_state << std::endl;
    std::cout << "m_lifeValue:" << m_lifeValue << std::endl;
    std::cout << "m_attackValue:" << m_attackValue << std::endl;
    std::cout << "m_defenceValue:" << m_defenceValue << std::endl;
}
